package luj.tool.jnproxyan.framework.proxy.actor.tell;

import luj.bean.api.bean.Bean;

import java.util.function.Supplier;

final class MBeanImpl<T> implements ActorTeller.MBean, ActorTeller.Field<T> {

  @SuppressWarnings("unchecked")
  @Override
  public <F> ActorTeller.Field<F> f(Supplier<F> f) {
    _field = (Supplier<T>) f;
    return (ActorTeller.Field<F>) this;
  }

  @Override
  public ActorTeller.MBean set(T val) {
    _bean.setField(_field, val);
    return this;
  }

  Bean<?> _bean;

  Supplier<T> _field;
}
